package 反射6;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;

public class Test {
    public static void main(String[] args) throws SQLException {
        /*int update = MyHandleDbReflection.insert("insert into goods values(null,?,?)","手环",500);
        System.out.println("已添加"+insert+"条信息");
        int delete = MyHandleDbReflection.insert("delete from goods where name=?","手环");
        System.out.println("已删除"+delete+"条信息");*/

        /*Object o = MyHandleDbReflection.queryBean("select * from goods where id=?", goods.class,1);
        System.out.println("o = " + o);*/

        /*ArrayList<Student> list = MyHandleDbReflection.queryBeanList("select * from student where major=?", Student.class, "计算机科学");
        System.out.println("list = " + list);*/


        /*Map<String, Object> stringObjectMap = MyHandleDbReflection.queryMap("select * from student where major=?","计算机科学");
        System.out.println("stringObjectMap = " + stringObjectMap);*/
//        Map接口的实现类hashmap、treemap等重写了toString方法


        /*ArrayList<Map> list = MyHandleDbReflection.queryMapList("select * from student where major=?", "计算机科学");
        System.out.println("list = " + list);*/


       /*Object[] arr = MyHandleDbReflection.queryArray("select * from student where sid=?", 201303);
        System.out.println("arr = " + arr);
        System.out.println("Arrays.toString(arr) = " + Arrays.toString(arr));*/


        ArrayList<Object[]> list = MyHandleDbReflection.queryArrList("select * from student where major=?", "计算机科学");
        System.out.println("list = " + list);
        //这里是返回了一个装有数组的集合，首先遍历集合中每一个元素（即数组），然后使用Arrays类中的toString方法转成字符串输出
        for (int i = 0; i < list.size(); i++) {
            Object[] objects = list.get(i);
            System.out.println(Arrays.toString(objects));
        }
    }
}
